package com.vitabuybuy.tv.ui.mine.order.after.adapter

import androidx.recyclerview.widget.RecyclerView
import com.vitabuybuy.tv.R
import com.vitabuybuy.tv.databinding.ItemAfterSaleBinding
import com.vitabuybuy.tv.dto.AfterSaleListDto
import com.library.common.base.BindRecycAdapter

class AfterSaleListAdapter : BindRecycAdapter<ItemAfterSaleBinding, AfterSaleListDto>() {
    override fun onBindViewHolder(
        mBinding: ItemAfterSaleBinding,
        itemData: AfterSaleListDto,
        holder: RecyclerView.ViewHolder,
        position: Int
    ) {
        mBinding.itemData = itemData
        mBinding.btnWatchDetail.setOnClickListener {
            onClickViewDetail.invoke(itemData.id)
        }
        when (itemData.status) {
            "售后成功" -> {
                mBinding.tvStatus.text = itemData.type + mContext.getString(R.string.refund_success)
            }
            "售后失败","售后关闭" -> {
                mBinding.tvStatus.text = itemData.type + mContext.getString(R.string.refund_failed)
            }
            "待审核" -> {
                mBinding.tvStatus.text = itemData.type + mContext.getString(R.string.wait_store_audit)
            }
            "待卖家处理" -> {
                mBinding.tvStatus.text = itemData.type + mContext.getString(R.string.wait_store_deal)
            }
            "待买家处理" -> {
                mBinding.tvStatus.text = itemData.type + mContext.getString(R.string.wait_buyer_deal)
            }
        }
    }

    lateinit var onClickViewDetail: (orderId: Int) -> Unit

    override fun normalViewId(viewType: Int): Int {
        return R.layout.item_after_sale
    }

}
